feat(javanet): Introduce configurable SecurityProviders and SSLSocketConfigurator for NetHttpTransport #2167
feat(javanet): Introduce configurable SecurityProviders and SSLSocketConfigurator for NetHttpTransport #2167lqiu96 wants to merge 1 commit into
Conversation
066bffb to
3497a47
Compare
3497a47 to
f4a7445
Compare
ac577db to
1e3ca17
Compare
f738eaf to
33defc8
Compare
7da5101 to
e165b84
Compare
76f358f to
38472fd
Compare
588e97c to
79c96d9
Compare
6bd5bc8 to
b57b752
Compare
b08e511 to
74932d4
Compare
| tmf.init((KeyStore) null); | ||
| trustManagers = tmf.getTrustManagers(); | ||
| } catch (Exception e) { | ||
| // Ignore and fall back to default |
There was a problem hiding this comment.
Why this case can be ignored? Shall we log it at least?
Also trustManagers will be null in this. case, would it cause issues when sslContext.init is called?
There was a problem hiding this comment.
Hmm, updating this so we just propagate errors instead. If we can't initialize the custom socket configuration, it may be better to just fail fast instead of silently change to JDK (I will assume there is a reason they require a specific securityprovideR)
| TrustManagerFactory tmf = SslUtils.getDefaultTrustManagerFactory(securityProvider); | ||
| tmf.init((KeyStore) null); | ||
| trustManagers = tmf.getTrustManagers(); | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
If we know what exactly the checked exceptions are, it is better to use the exact exception.
There was a problem hiding this comment.
i'm going to remove catching exceptions alltogether
| } | ||
| sslContext.init(null, trustManagers, null); | ||
| return sslContext.getSocketFactory(); | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
Same comment as https://github.com/googleapis/google-http-java-client/pull/2167/changes#r3605325675. Unless it is meant to be a "catch all and fall back to default" case.
There was a problem hiding this comment.
Updated. On second thought, I don't think we should fall back to the default. I think fail-fast would make more sense here
6f9fed1 to
d84c251
Compare
…cketConfigurator callback Introduces SslSocketConfigurator interface and ConfigurableSSLSocketFactory wrapper. ConfigurableSSLSocketFactory wraps the active SSLSocketFactory, intercepts socket creation, and invokes the configurator callback, enabling client-level socket configuration (e.g. for Conscrypt or BouncyCastle). Includes JreNamedGroupsSslSocketConfigurator implementing reflective named groups configuration natively on JDK 20+. Removes obsolete wrapTrustManagers code and animal-sniffer dependencies from SslUtils. TAG=agy CONV=385b9ab5-874c-4c9a-b331-66dab51fef61
Adds support to configure the SSLSocket. This change allows users a method to enable Post Quantum Cryptography (PQC), but can be used for any other SSLSocket configuration. Allows a method for to configure a SecurityProvider and modify the the corresponding socket factory with the SecurityProvider.
There is no default SecurityProvider set in the http-client and Gax and Java-Core will bundle Conscrypt by default as pass it into the http-client. The Java SDK uses Conscrypt as the default SecurityProvider for PQC and will use the Conscrypt native APIs (e.g. Conscrypt.setNamedGroups) via the SslSocketConfigurator interface.
Changes: